const app = getApp()

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    images: Array
  },

  /**
   * 组件的初始数据
   */
  data: {
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    circular: false,
    interval: 2000,
    duration: 500,
    previousMargin: 0,
    nextMargin: 0,
    BASE_IMG_URL: app.globalData.BASE_IMG_URL
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 点击轮播图跳转
     * 这里不能使用箭头函数，否则 triggerEvent 无效
     */
    onTap: function(e) {
      const {
        index
      } = e.currentTarget.dataset

      var myEventDetail = {
        index
      } // detail对象，提供给事件监听函数
      var myEventOption = {
        // myEventOption: 2
      } // 触发事件的选项

      // this.triggerEvent('mySwiperEvent', myEventDetail, myEventOption)
    },
    changeProperty: function(e) {
      var propertyName = e.currentTarget.dataset.propertyName
      var newData = {}
      newData[propertyName] = e.detail.value
      this.setData(newData)
    },
    changeIndicatorDots: function(e) {
      this.setData({
        indicatorDots: !this.data.indicatorDots
      })
    },
    changeAutoplay: function(e) {
      this.setData({
        autoplay: !this.data.autoplay
      })
    },
    intervalChange: function(e) {
      this.setData({
        interval: e.detail.value
      })
    },
    durationChange: function(e) {
      this.setData({
        duration: e.detail.value
      })
    }
  }
})